{{!-- 
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
--}}
<div class="serviceInfo">
    <div>
        <p>
            <strong>{{tt 'lbl.serviceName'}} :</strong> {{PolicyDetails.service}}
        </p>
    </div>
    <div>
        <p>
            <strong>{{tt 'lbl.serviceType'}} :</strong> {{PolicyDetails.serviceType}}
        </p>
    </div>
</div>
<div id="policyDetails">
    <p class="formHeader">
        {{tt 'h.policyDetails'}} :
    </p>
    <div class="table-responsive">
        <table class="table table-bordered table-condensed">
            <tbody>
                <tr>
                    <td>
                        {{tt 'lbl.policyType'}}
                    </td>
                    <td>
                        <div class="controls"><label class="badge badge-ranger" style="cursor: auto;">{{policyType}}</label></div>
                    </td>
                </tr>
                <tr>
                    <td>
                        {{tt 'lbl.policyId'}}
                    </td>
                    <td>
                        <div class="controls"><label class="badge badge-ranger" style="cursor: auto;">{{PolicyDetails.id}}</label></div>
                    </td>
                </tr>
                <tr>
                    <td>
                        {{tt 'lbl.version'}}
                    </td>
                    <td>
                        <div class="controls"><label class="badge badge-ranger" style="cursor: auto;">{{PolicyDetails.version}}</label></div>
                    </td>
                </tr>
                <tr>
                    <td>
                        {{tt 'lbl.policyName'}}
                    </td>
                    <td>
                        <span>{{PolicyDetails.name}}</span>
                        <div class="text-right">
                            <span class="badge badge-dark">{{PolicyDetails.policyPriority}}</span>
                            <span class="badge badge-dark m-r-xs">{{PolicyDetails.isEnabled}}</span>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>
                        {{tt 'lbl.policyLabels'}}
                    </td>
                    <td>
                        {{#ifCond PolicyDetails.policyLabels.length '==' "0"}}
                            --
                        {{else}}
                            {{#each PolicyDetails.policyLabels}}
                                <span class="badge badge-dark ">{{this}}</span>
                            {{/each}}
                        {{/ifCond}}
                    </td>
                </tr>
                {{#each PolicyDetails.resources}}
                    <tr>
                        <td>
                            {{this.label}}
                        </td>
                        <td>
                            {{#each this.values}}
                                <span class="badge badge-info">{{this}}</span>
                            {{/each}}
                            <span class="badge badge-dark pull-right m-l-sm">{{this.Rec_Recursive}}</span>
                            <span class="badge badge-dark pull-right">{{this.Rec_Exc}}</span>
                        </td>
                    </tr>
                {{/each}}
                <tr>
                    <td>
                        {{tt 'lbl.description'}}
                    </td>
                    {{#ifCond PolicyDetails.description '==' ""}}
                        <td>
                            --
                        </td>
                    {{else}}
                        <td>
                            {{PolicyDetails.description}}
                        </td>
                    {{/ifCond}}
                </tr>
                <tr>
                    <td>
                        {{tt 'lbl.auditLogging'}}
                    </td>
                    <td>
                        <span class="badge badge-info">{{PolicyDetails.isAuditEnabled}}</span>
                    </td>
                </tr>
                <tr>
                    {{#if PolicyDetails.zoneName}}
                        <td>{{tt 'lbl.zoneName'}}</td>
                        <td>
                            {{#if PolicyDetails.zoneName}}
                                <span class="badge badge-dark">{{PolicyDetails.zoneName}}</span>
                            {{else}}
                                <span>--</span>
                            {{/if}}
                        </td>
                    {{/if}}
                </tr>
            </tbody>
        </table>
    </div>
</div>
{{#if PolicyDetails.validitySchedules}}
    <div id="policyItems" class="">
        <p class="formHeader">Validity Period :<i class="fa-fw fa fa-time fa-fw fa fa-large pull-right"></i></p>
        <div class="table-responsive">
            <table class="table table-permission table-condensed table-read-only" style="width: 100%">
                <thead>
                    <tr>
                        <th>Start Time</th>
                        <th>End Time</th>
                        <th>Time zone</th>
                    </tr>
                </thead>
                <tbody>
                    {{#each PolicyDetails.validitySchedules}}
                        <tr>
                            <th>{{blankCheck this.startTime}}</th>
                                <th>{{blankCheck this.endTime}}</th>
                                <th>
                                    {{#if this.timeZone}}
                                        <span class="badge badge-info">{{this.timeZone}}</span>
                                    {{else}}
                                        --
                                    {{/if}}
                                </th>
                        </tr>
                    {{/each}}
                </tbody>
            </table>
        </div>
    </div>
{{/if}}
{{#if PolicyDetails.conditions}}
    <div class="">
        <p class="formHeader">Policy Conditions :</p>
        <div class="table-responsive">
            <table class="table table-bordered condition-group-table" style="width: 100%">
                <tbody>
                    {{#each PolicyDetails.conditions}}
                        <tr colspan="2">
                            <td width="40%">{{this.name}}</td>
                            <td width="60%">{{this.values}}</td>
                        </tr>
                    {{/each}}
                </tbody>
            </table>
        </div>
    </div>
{{/if}}
{{#each PolicyDetails.policyItemsCond}}
    <div id="policyItems" class="">
        <p class="formHeader">
            {{this.title}}  :
        </p>
        <div class="table-responsive">
            <table class="table table-permission table-condensed table-read-only" style="width:100%">
                <thead>
                    <tr>
                        {{#each this.headers}}
                            <th>{{this}}</th>
                        {{/each}}
                    </tr>
                </thead>
                <tbody>
                    {{#ifCond this.policyItems.length '==' "0"}}
                        <td class="emptySet text-muted" colspan='{{this.headers.length}}'>No Data Found !!</td>
                    {{else}}
                        {{#each this.policyItems}}
                            <tr>
                                <td>
                                    {{#if this.roles}}
                                        {{#each this.roles}}
                                            <span class="badge badge-info">{{this}}</span>
                                        {{/each}}
                                    {{else}}
                                        --
                                    {{/if}}
                                </td>
                                <td>
                                    {{#if this.groups}}
                                        {{#each this.groups}}
                                            <span class="badge badge-info">{{this}}</span>
                                        {{/each}}
                                    {{else}}
                                        --
                                    {{/if}}
                                </td>
                                <td>
                                    {{#if this.users}}
                                        {{#each this.users}}
                                            <span class="badge badge-info">{{this}}</span>
                                        {{/each}}
                                    {{else}}
                                        --
                                    {{/if}}
                                </td>
                                {{#if ../../PolicyDetails.policyCondition}}
                                    <td>
                                        {{#if this.conditions}}	
                                            {{#each this.conditions}}
                                                <span class="badge badge-info">
                                                    {{this.type}} :
                                                        {{#each this.values}}
                                                            {{this}}
                                                        {{/each}}
                                                </span>
                                            {{/each}}
                                        {{else}}
                                            --  
                                        {{/if}}
                                    </td>
                                {{/if}}
                                <td>
                                    {{#each this.accesses}}
                                        <span class="badge badge-info">{{#if this.isAllowed}}{{this.type}}{{/if}}</span>
                                    {{/each}}
                                </td>
                                {{#if this.dataMaskInfo}}
                                    {{#ifCond this.dataMaskInfo.dataMaskType '==' "CUSTOM"}}
                                        <td>
                                            <span class="badge badge-info ">{{this.dataMaskInfo.label}}  :  {{this.dataMaskInfo.valueExpr}} </span>
                                        </td>
                                    {{else}}
                                        <td>
                                            <span class="badge badge-info">{{this.dataMaskInfo.label}}</span>
                                        </td>
                                    {{/ifCond}}
                                {{/if}}
                                {{#if this.rowFilterInfo}}
                                    <td>
                                        {{#if this.rowFilterInfo.filterExpr}}
                                            <span class="badge badge-info">{{this.rowFilterInfo.filterExpr}}</span>
                                        {{else}}
                                            --
                                        {{/if}}
                                    </td>
                                {{/if}}
                                {{#if ../../isDelegatAdmin}}
                                    <td>
                                        <input type="checkbox" {{#if this.delegateAdmin}}checked{{/if}} disabled="disabled">
                                    </td>
                                {{/if}}
                            </tr>
                        {{/each}}
                    {{/ifCond}}
                </tbody>
            </table>
        </div>
    </div>
    {{#compare "Exclude from Allow Conditions" "eq" this.title}}
        {{#if ../isDenyAllElse}}
            <div class="deny-all-else">
                <tr>
                    <td>
                        <b>{{tt 'lbl.isDenyAllElse'}} : </b>
                    </td>
                    <td>
                        <span class="badge badge-dark">{{ ../PolicyDetails.isDenyAllElse}}</span>
                    </td>
                </tr>
            </div>
        {{/if}}
    {{/compare}}
{{/each}}
<div class="updateInfo">
    <div class="pull-left">
        <p>
            <strong>{{tt 'lbl.updatedBy'}} :</strong> {{PolicyDetails.updatedBy}}
        </p>
        <p>
            <strong>{{tt 'lbl.updatedOn'}} :</strong> {{PolicyDetails.updateTime}}
        </p>
    </div>
    <div class="pull-right">
        <p>
            <strong>{{tt 'lbl.createdBy'}} :</strong> {{PolicyDetails.createdBy}}
        </p>
        <p>
            <strong>{{tt 'lbl.createdOn'}} :</strong> {{PolicyDetails.createTime}}
        </p>
    </div>
</div>